package com.ruibang.glass.purchase.controller;


import com.ruibang.glass.purchase.domain.req.PurchaseRawReq;
import com.ruibang.glass.purchase.entity.ProcuresRawMaterialInspection;
import com.ruibang.glass.purchase.service.ProcuresRawMaterialInspectionService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author mameng
 * 原材料验收单
 */
@Api(tags = "原材料验收单")
@RestController
@RequestMapping("/api/glass/purchase/raw/material")
public class PurchaseRawMaterialController {
    @Autowired
    private ProcuresRawMaterialInspectionService procuresRawMaterialInspectionService;


    @PostMapping("/list")
    @ApiOperation(value = "原材料列表", response = ResultBody.class)
    public ResultBody queryList(@RequestBody PurchaseRawReq purchaseRawReq) {
        return ResultBody.success(procuresRawMaterialInspectionService.getPage(purchaseRawReq));
    }


    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody queryList(@PathVariable("id")String id) {
        return ResultBody.success(procuresRawMaterialInspectionService.getById(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增", response = ResultBody.class)
    public ResultBody add(@RequestBody ProcuresRawMaterialInspection procuresRawMaterialInspection) {
        procuresRawMaterialInspectionService.addProcuresRawMaterialInspection(procuresRawMaterialInspection);
        return ResultBody.success();
    }

    @GetMapping("/getNumber/{arrivalNumber}")
    @ApiOperation(value = "获取编号", response = ResultBody.class)
    public ResultBody getNumber(@PathVariable("arrivalNumber")String arrivalNumber) {
        return ResultBody.success(procuresRawMaterialInspectionService.getNumber(arrivalNumber));
    }

    @PostMapping("/updateProcuresRawMaterialInspection")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateProcuresRawMaterialInspection(@RequestBody ProcuresRawMaterialInspection procuresRawMaterialInspection) {
        procuresRawMaterialInspectionService.updateById(procuresRawMaterialInspection);
        return ResultBody.success();
    }

}
